package com.example.entity;

import java.util.Date;

public class User {
    private Integer userid;
    private String username;
    private String password;
    private String phone;
    private String sex;     // 性别
    private Integer age;    // 年龄
    private Double height;  // 身高(cm)
    private Double weight;  // 体重(kg)
    private String bmi;     // BMI值
    private Date createtime; // 创建时间
    private Integer role;

    @Override
    public String toString() {
        return "User{" +
                "userid=" + userid +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", phone='" + phone + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", height=" + height +
                ", weight=" + weight +
                ", bmi='" + bmi + '\'' +
                ", createtime=" + createtime +
                ", role='" + role + '\'' +
                '}';
    }

    // getter和setter方法


    public Integer getUserid() {
        return userid;
    }

    public void setUserid(Integer userid) {
        this.userid = userid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Double getHeight() {
        return height;
    }

    public void setHeight(Double height) {
        this.height = height;
    }

    public Double getWeight() {
        return weight;
    }

    public void setWeight(Double weight) {
        this.weight = weight;
    }

    public String getBmi() {
        return bmi;
    }

    public void setBmi(String bmi) {
        this.bmi = bmi;
    }

    public Date getCreatetime() {
        return createtime;
    }

    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }

    public Integer getRole() {
        return role;
    }

    public void setRole(Integer role) {
        this.role = role;
    }

    // 添加计算BMI的方法
    public void calculateBmi() {
        if (height != null && weight != null && height > 0) {
            // BMI = 体重(kg) / (身高(m) × 身高(m))
            double heightInMeters = height / 100.0;
            double bmiValue = weight / (heightInMeters * heightInMeters);
            this.bmi = String.format("%.2f", bmiValue);
        }
    }

    public Object getId() {
        return userid;
    }
}